package com.edu.service.impl;

import com.edu.bean.Shop;
import com.edu.mapper.GoodsMapper;
import com.edu.mapper.ShopMapper;
import com.edu.service.ShopService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;
@Service
public class ShopServiceImpl implements ShopService {

    @Resource
    private ShopMapper shopMapper;
    @Resource
    private GoodsMapper goodsMapper;
    @Override
    public int addShop(Shop shop) {
        return shopMapper.insertShop(shop);
    }

    @Override
    @Transactional
    public int delShop(int shopId) {
        shopMapper.delShop(shopId);
        goodsMapper.delGoods(shopId);
        return 1;
    }

    @Override
    public List<Shop> selectShops(String shopName) {
        return shopMapper.selectShops(shopName);
    }
}
